package com.aspose.cells;

class zhj extends zj {
   private static double[] c = new double[]{0.95D, 9.5D, 99.5D, 999.5D, 9999.5D, 99999.5D, 999999.5D, 9999999.5D, 9.99999995E7D, 9.999999995E8D, 9.9999999995E9D, 9.99999999995E10D, 9.999999999995E11D, 9.9999999999995E12D, 9.99999999999995E13D, 9.999999999999995E14D, 1.0E16D};
   private zafy d;
   private zafy e;
   private char f;
   private boolean g;
   private boolean h;
   private boolean i;

   public zhj(zhh var1, zj var2, zj var3) {
      super(var1, "");
      this.a(this.a.b());
      this.d = var2;
      this.e = var3;
      this.i = false;
      this.g = false;
      this.h = false;
      if (var2 != null) {
         this.i = true;
         if (var2.a() == 3 && ((zl)var2).f()) {
            this.g = true;
         }
      }

      if (var3 != null) {
         this.i = true;
         if (var3.a() == 3 && ((zl)var3).f()) {
            this.h = true;
         }
      }

   }

   public zafy c() {
      return this.d;
   }

   public zafy d() {
      return this.e;
   }

   protected void a(char[] var1, int var2, int var3) {
   }

   public zxz a(zxu var1, int var2, Object var3) {
      zxz var4 = super.a(var1, var2, var3);
      if (var4.f() != 7) {
         return var4;
      } else {
         switch(var2) {
         case 9:
            int var5 = (Integer)var3;
            this.a(var1, (double)var5, var4);
            return var4;
         case 14:
            this.a(var1, (Double)var3, var4);
            return var4;
         case 16:
            this.a(var1, this.a((DateTime)var3), var4);
            return var4;
         default:
            this.a(var3, var2, var4);
            return var4;
         }
      }
   }

   private void a(zxu var1, double var2, zxz var4) {
      boolean var5;
      if (var2 < 0.0D) {
         var5 = true;
         var2 = -var2;
      } else {
         var5 = false;
      }

      zxz var6 = null;
      zxz var7 = null;
      if (this.i) {
         if (var5 && (this.g || this.h)) {
            var4.a(var1.b());
            return;
         }

         if (this.d != null) {
            var6 = this.d.a(var1, 14, var2);
            if (var6.e()) {
               var4.a(var1.b());
               return;
            }
         }

         if (this.e != null) {
            var7 = this.e.a(var1, 14, var2);
            if (var7.e()) {
               var4.a(var1.b());
               return;
            }
         }
      }

      int var8;
      StringBuilder var9;
      if (var1.a() == null) {
         var8 = this.a.b().l();
      } else {
         var9 = null;
         if (this.i) {
            var9 = new StringBuilder();
            if (var6 != null) {
               var9.append(var6.a(0, false));
            }

            if (var7 != null) {
               var9.append(var7.a(0, false));
            }
         }

         var8 = var1.a().a(var9 == null ? null : com.aspose.cells.b.a.zr.a(var9), var5);
      }

      if (var8 < 1) {
         var4.a(var1.b());
      } else {
         var9 = null;
         String var14;
         if (var2 == 0.0D) {
            var14 = "0";
         } else {
            var14 = this.a(var1, var2, var8);
            if (var14 == null) {
               var4.a(var1.b());
               return;
            }
         }

         char[] var10 = var14.toCharArray();
         char[] var11;
         if (this.i) {
            var11 = new char[(var5 ? 1 : 0) + (var6 != null && !var6.c() ? var6.g().length : 0) + var10.length + (var7 != null && !var7.c() ? var7.g().length : 0)];
            int var12 = 0;
            if (var5) {
               var11[0] = '-';
               var12 = 1;
            }

            char[] var13;
            if (var6 != null) {
               this.a(var4, var6, var12);
               if (!var6.c()) {
                  var13 = var6.g();
                  System.arraycopy(var13, 0, var11, 0, var13.length);
                  var12 += var13.length;
               }
            }

            System.arraycopy(var10, 0, var11, var12, var10.length);
            var12 += var10.length;
            if (var7 != null) {
               this.a(var4, var7, var12);
               if (!var7.c()) {
                  var13 = var7.g();
                  System.arraycopy(var13, 0, var11, var12, var13.length);
                  int var10000 = var12 + var13.length;
               }
            }

            var10 = var11;
         } else if (var5) {
            var11 = new char[var10.length + 1];
            var11[0] = '-';
            System.arraycopy(var10, 0, var11, 1, var10.length);
            var10 = var11;
         }

         var4.a(2, (char[])var10);
      }
   }

   private String a(zxu var1, double var2, int var4) {
      if (var2 == 0.0D) {
         return "0";
      } else if (var2 >= 9999.5D) {
         if (var4 < 5) {
            return null;
         } else {
            StringBuilder var12 = new StringBuilder(var4);
            int var9 = (int)Math.log10(var2);
            if (var2 >= c[var4]) {
               var4 -= var9 > 99 ? 7 : 6;
               if (var4 > 0) {
                  var2 /= Math.pow(10.0D, (double)(var9 - var4));
               } else {
                  var2 /= Math.pow(10.0D, (double)var9);
               }

               var12.append((long)(var2 + 0.5D));
               if (var12.length() > (var4 > 0 ? var4 + 1 : 1)) {
                  ++var9;
               }

               this.a(var12, 0);
               this.c(var12, var9);
            } else {
               if (var4 > var9 + 2) {
                  var2 *= Math.pow(10.0D, (double)(var4 - (var9 + 2)));
               }

               var12.append((long)(var2 + 0.5D));
               if (var12.length() > (var4 >= var9 + 2 ? var4 - 1 : var4)) {
                  ++var9;
               }

               this.a(var12, var9);
               if (var12.length() > var9 + 1) {
                  var12.insert(var9 + 1, this.f);
               }
            }

            return com.aspose.cells.b.a.zr.a(var12);
         }
      } else {
         int var5;
         StringBuilder var6;
         if (var2 < 1.0D) {
            var5 = -((int)Math.floor(Math.log10(var2)));
            if (var5 >= var4 - 1) {
               if (var4 < 5) {
                  return "0";
               } else {
                  var6 = new StringBuilder(var4);
                  var4 -= var5 > 99 ? 7 : 6;
                  if (var4 > 0) {
                     var2 *= Math.pow(10.0D, (double)(var4 + var5));
                  } else {
                     var2 *= Math.pow(10.0D, (double)var5);
                  }

                  var6.append((long)(var2 + 0.5D));
                  if (var6.length() > (var4 > 0 ? var4 + 1 : 1)) {
                     --var5;
                  }

                  this.a(var6, 0);
                  this.c(var6, -var5);
                  return com.aspose.cells.b.a.zr.a(var6);
               }
            } else {
               var6 = new StringBuilder(var4);
               if (var4 >= 5 && var5 >= 4 && var4 != 6) {
                  if (var5 == 4) {
                     String var10 = Long.toString((long)(var2 * Math.pow(10.0D, (double)(var4 - 2)) + 0.5D));
                     if (var10.length() > var4 - 5) {
                        this.b(var6, 3);
                        var6.append(var10.charAt(0));
                        return com.aspose.cells.b.a.zr.a(var6);
                     }
                  }

                  if (var4 > 6) {
                     var2 *= Math.pow(10.0D, (double)(var4 + var5 - 6));
                  } else {
                     var2 *= Math.pow(10.0D, (double)var5);
                  }

                  var6.append((long)(var2 + 0.5D));
                  boolean var11 = false;
                  if (var6.length() > var4 - 5) {
                     --var5;
                     var11 = true;
                  }

                  this.a(var6, 0);
                  if (!var11 && var6.length() < var4 - var5) {
                     String var8 = com.aspose.cells.b.a.zr.a(var6);
                     var6.setLength(0);
                     this.b(var6, var5);
                     var6.append(var8);
                  } else {
                     this.c(var6, -var5);
                  }

                  return com.aspose.cells.b.a.zr.a(var6);
               } else {
                  this.b(var6, var5);
                  int var7 = var6.length();
                  var6.append((long)(var2 * Math.pow(10.0D, (double)(var4 - 2)) + 0.5D));
                  if (var6.length() - var7 > var4 - 1 - var5) {
                     if (var5 > 1) {
                        var6.delete(var7 - 1, var7 - 1 + 1);
                        var7 -= 2;
                     } else {
                        var6.delete(0, 2);
                        var7 = 0;
                     }
                  }

                  this.a(var6, var7);
                  return com.aspose.cells.b.a.zr.a(var6);
               }
            }
         } else if (var2 >= c[var4]) {
            return null;
         } else {
            if (var2 >= 1000.0D) {
               var5 = 3;
            } else if (var2 >= 100.0D) {
               var5 = 2;
            } else if (var2 >= 10.0D) {
               var5 = 1;
            } else {
               var5 = 0;
            }

            if (var4 > var5 + 2) {
               var2 *= Math.pow(10.0D, (double)(var4 - var5 - 2));
            }

            var6 = new StringBuilder(var4);
            var6.append((long)(var2 + 0.5D));
            if (var6.length() > (var4 >= var5 + 2 ? var4 - 1 : var4)) {
               ++var5;
            }

            this.a(var6, var5);
            if (var6.length() > var5 + 1) {
               var6.insert(var5 + 1, this.f);
            }

            return com.aspose.cells.b.a.zr.a(var6);
         }
      }
   }

   private void a(StringBuilder var1, int var2) {
      int var3;
      for(var3 = var1.length() - 1; var3 > var2 && var1.charAt(var3) == '0'; --var3) {
         ;
      }

      var1.setLength(var3 + 1);
   }

   private void b(StringBuilder var1, int var2) {
      var1.append('0');
      var1.append(this.f);

      for(int var3 = 1; var3 < var2; ++var3) {
         var1.append('0');
      }

   }

   private void c(StringBuilder var1, int var2) {
      if (var1.length() > 1) {
         var1.insert(1, this.f);
      }

      var1.append("E");
      if (var2 >= 0) {
         var1.append('+');
      } else {
         var1.append('-');
         var2 = -var2;
      }

      if (var2 < 10) {
         var1.append('0');
      }

      var1.append(var2);
   }

   public int a() {
      return 0;
   }

   public int g() {
      return 0;
   }

   private void a(zxx var1) {
      this.f = var1.f().d();
   }
}
